package com.xvyy.tingshu.search.locktest;

import com.xvyy.tingshu.common.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: TestController
 * Package: com.xvyy.tingshu.search.locktest
 *
 * @Description:
 * @Author: xvyy
 * @Create: 2025/2/6 - 12:49
 * @Version: v1.0
 */
@RestController
@RequestMapping("api/search/local")//走网关
public class TestLockController {

    //  注入服务层方法
    @Autowired
    private TestLockService testLockService;

    /**
     * 测试本地锁
     *
     * @return
     */
    @GetMapping("/testLocalLock")
    @Operation(summary = "测试本地锁")
    public Result testLocalLock() {
        testLockService.testLocalLock();
        return Result.ok();
    }

    /**
     * 测试分布式锁
     *
     * @return
     */
    @GetMapping("/testDistributedLock")
    @Operation(summary = "测试分布式锁")
    public Result testDistributedLock() {
        testLockService.testDistributedLock();
        return Result.ok();
    }

    /**
     * 测试分布式Redisson锁（基于Redis）
     *
     * @return
     */
    @GetMapping("/testDistributedRedissonLock")
    @Operation(summary = "测试分布式Redisson锁")
    public Result testDistributedRedissonLock() {
        testLockService.testDistributedRedissonLock();
        return Result.ok();
    }


}
